package org.wu.framework.authorization.platform.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.authorization.platform.application.SysUserRoleApplication;
import org.wu.framework.authorization.platform.application.command.SysUserRoleCommand;
import org.wu.framework.authorization.platform.infrastructure.entity.SysUserRoleDO;
import org.wu.framework.authorization.platform.domain.model.sys.user.role.SysUserRole;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController;
import org.wu.framework.lazy.orm.web.plus.AbstractLazyCrudProvider;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.spring.EasyController;

import java.util.List;

/**
 * describe 用户角色关联关系
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyController
 **/
@Tag(name = "用户角色关联关系提供者")
@EasyController("/user/role")
public class SysUserRoleProvider extends AbstractLazyCrudProvider<SysUserRoleDO, SysUserRoleDO, Long> {

    @Autowired
    private SysUserRoleApplication sysUserRoleApplication;

    /**
     * describe 新增用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @PostMapping("/story")
    public Result<SysUserRole> story(@RequestBody SysUserRoleCommand sysUserRoleCommand) {
        return sysUserRoleApplication.save(sysUserRoleCommand);
    }

    /**
     * describe 更新用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @PutMapping("/updateOne")
    public Result<SysUserRole> updateOne(@RequestBody SysUserRoleCommand sysUserRoleCommand) {
        return sysUserRoleApplication.update(sysUserRoleCommand);
    }

    /**
     * describe 查询单个用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @GetMapping("/findOne")
    public Result<SysUserRole> findOne(@ModelAttribute SysUserRoleCommand sysUserRoleCommand) {
        return sysUserRoleApplication.findOne(sysUserRoleCommand);
    }

    /**
     * describe 查询多个用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @GetMapping("/findList")
    public Result<List<SysUserRole>> findList(@ModelAttribute SysUserRoleCommand sysUserRoleCommand) {
        return sysUserRoleApplication.findList(sysUserRoleCommand);
    }

    /**
     * describe 删除用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @DeleteMapping("/delete")
    public Result<SysUserRole> delete(@ModelAttribute SysUserRoleCommand sysUserRoleCommand) {
        return sysUserRoleApplication.delete(sysUserRoleCommand);
    }
}